CSV: if date is before 1/1/1970, don't crash on Windows.
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Sun, 6 Apr 2008 04:36:38 +0000 (04:36 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Sun, 6 Apr 2008 04:36:38 +0000 (04:36 +0000)
git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@3171 f51c46e8-681c-474f-0cfe-069cfd0219fb

gpsbabel/csv_util.c

index 14c1e5040cf57f9404965e19e669fb5218a1dca6..5b662743d2e6c275e099f33c0042c12865415fa7 100644 (file)
@@ -848,13 +848,16 @@ static
 int 
 writehms(char * buff, size_t bufsize, const char * format, time_t t, int gmt )
 {
-       static struct tm * stmp;
+       static struct tm no_time = {0};
+       static struct tm * stmp = &no_time;
 
        if (gmt)
                stmp = gmtime(&t);
        else
                stmp = localtime(&t);
 
+       if (stmp == NULL) stmp = &no_time;
+
        return snprintf(buff, bufsize, format, 
                stmp->tm_hour, stmp->tm_min, stmp->tm_sec, 
                (stmp->tm_hour>=12?"PM":"AM") );